﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Kooboo.Web.Mvc.Paging;
using System.Web.Mvc;

namespace Kooboo.Web.UI
{
    public static class PagerHelper
    {
        public static MvcHtmlString FrontPager<T>(this HtmlHelper helper, PagedList<T> pagedList)
        {
            var pagerOptions = new PagerOptions
            {
                AutoHide = true,
                PageIndexParameterName = "page",
                NumericPagerItemCount = 10,
                AlwaysShowFirstLastPageNumber = false,
                ShowPrevNext = true,
                PrevPageText = "Previous",
                NextPageText = "Next",
                ShowNumericPagerItems = true,
                ShowFirstLast = false,
                FirstPageText = "First",
                LastPageText = "Last",
                ShowMorePagerItems = true,
                MorePageText = "...",
                ShowDisabledPagerItems = true,
                SeparatorHtml = "&nbsp;&nbsp;",
                ContainerTagName = "div",
                ShowPageIndexBox = false,
                ShowGoButton = true,
                PageIndexBoxType = PageIndexBoxType.TextBox,
                MaximumPageIndexItems = 80,
                GoButtonText = "Go",
                InvalidPageIndexErrorMessage = "Invalid page index",
                PageIndexOutOfRangeErrorMessage = "Page index out of range",
                CurrentPagerItemWrapperFormatString = "<span class=\"current\">{0}</span>"
            };

            return helper.Pager(pagedList.TotalPageCount, pagedList.CurrentPageIndex, null, null, pagerOptions, null, null, null);
        }
    }
}